import pygal
from c_15.die import Die
# 创建三个D6
die_1 = Die()
die_2 = Die()
die_3 = Die()
# 创建D8 D9:die_5 = Die(9)
# die_4 = Die(8)

# 掷几次骰子，并将结果存储在一个列表中,数字可以更改。
results = [die_1.roll()+die_2.roll()+die_3.roll() for roll_num in range(1000)]
# 分析结果
max_result = die_1.num_sides+die_2.num_sides+die_3.num_sides
frequencies = [results.count(v) for v in range(3, max_result+1)]
# 对结果进行可视化
hist = pygal.Bar()
hist.title = "Results of rolling three D6 dice 1000 times."
hist.x_labels = [str(labels) for labels in range(3, max_result+1)]
hist.x_title = "Result"
hist.y_title = "Frequency of Result"
hist.add('D6+D6+D6', frequencies)
hist.render_to_file('15-8.svg')
